<% include header.ejs %>
<nav id="backState">
	<div>
		<a href="/" >首页</a>
		<span ><%= title %></span>
	</div>
</nav>
<p style="height: 44px;margin-right: 20px;"></p>
<div style="max-width: 1226px;margin: 10px auto">
	<table class="table table-bordered table-hover" style="text-align: center;">
		<tr class="success">
			<td>品名</td>
			<td>城市</td>
			<td>价格</td>
			<td>发布人</td>
			<td>发布日期</td>
			<td>操作</td>
		</tr>
		<% posts.forEach(function (post,index) {%>
		<tr>
			<td><%= post.title %></td>
			<td><%= post.city %></td>
			<td><%= post.price %></td>
			<td><%= post.users.userName %></td>
			<td><%= post.date %></td>
			<td>
			    <a href="/post" style="color: green">增加</a>&nbsp
				<a href="/modify?_id=<%= post._id %>"  style="color: blue">修改</a>&nbsp
				<a onclick="del('<%= post._id %>')" style="color: red">删除</a>
				<a id='deletePost' href="/deletePost?_id=<%= post._id %>" style="display: none;">删除隐藏</a>
			</td>
		</tr>
		<%})%>
	</table>
<% include footer.ejs %>
<script>
		function del(id){
			var c = confirm('确定删除？');
			if ( c ) {
				document.getElementById('deletePost').click();
			}
		}
</script>
